<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.2"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Hardware Abstraction Layer (HAL)</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="logo.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Hardware Abstraction Layer (HAL)</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.2 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(document).ready(function(){initNavTree('group__group__hal__dac.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#groups">API Reference</a> &#124;
<a href="#enum-members">Enumerations</a> &#124;
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle"><div class="title">DAC (Digital to Analog Converter)<div class="ingroups"><a class="el" href="group__group__hal.html">HAL Drivers</a></div></div></div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p >High level interface for interacting with the digital to analog converter (DAC). </p>
<p >This block drives a pin with a firmware configurable voltage. See the device datasheet for details on which pins support DAC output.</p>
<h1><a class="anchor" id="subsection_dac_features"></a>
Features</h1>
<p >The DAC driver provides APIs to:</p><ul>
<li>Configure and work with the DAC hardware</li>
<li>Update the DAC output value</li>
<li>Read the DAC output voltage setting</li>
</ul>
<dl class="section note"><dt>Note</dt><dd>The <a class="el" href="group__group__hal__dac.html#gabb6bdec361f3805b7086cef3ea3b9d56">cyhal_dac_write</a> and <a class="el" href="group__group__hal__dac.html#ga2ad162f2317e6f1666d7eadebbddca82">cyhal_dac_read</a> APIs are defined as 16-bit, which may not match the underlying hardware. The functions will linearly scale the 16-bit value to and from a resolution that hardware is capable of outputting. For instance, if the device supports 12-bit resolution, only the 12 MSBs of the 16-bit value will be used. Refer to BSP Settings section in the kit's BSP API Reference Manual for details on the DAC's output range.</dd></dl>
<h1><a class="anchor" id="subsection_dac_quickstart"></a>
Quick Start</h1>
<p >Call <a class="el" href="group__group__hal__dac.html#gaa33e893eccc66deff01287434a847687">cyhal_dac_init</a> to initialize a DAC instance by providing the DAC object ( <b> obj </b> ) and an output pin (<b> pin </b>).</p>
<p >See <a class="el" href="group__group__hal__dac.html#subsection_dac_use_case_1">Use case 1: Simple DAC initialization</a>.</p>
<h1><a class="anchor" id="subsection_dac_snippets"></a>
Code Snippets</h1>
<h2><a class="anchor" id="subsection_dac_use_case_1"></a>
Use case 1: Simple DAC initialization</h2>
<p >The following snippet initializes a DAC resource and assigns the output to the specified <b>pin</b> using <a class="el" href="group__group__hal__dac.html#gaa33e893eccc66deff01287434a847687">cyhal_dac_init</a>. <a class="el" href="group__group__hal__dac.html#gabb6bdec361f3805b7086cef3ea3b9d56">cyhal_dac_write</a> is used to set the DAC output value. <a class="el" href="group__group__hal__dac.html#ga2ad162f2317e6f1666d7eadebbddca82">cyhal_dac_read</a> is used to read back DAC register. </p><div class="fragment"><div class="line">    <a class="code hl_struct" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> my_dac_obj;</div>
<div class="line">    <a class="code hl_typedef" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>   dac_result;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Full Scale value for the DAC</span></div>
<div class="line">    uint16_t dac_value = 0xFFFF;</div>
<div class="line">    uint16_t dac_read;</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Initialize DAC, set Pin 9[6] as the DAC output</span></div>
<div class="line">    dac_result = <a class="code hl_function" href="group__group__hal__dac.html#gaa33e893eccc66deff01287434a847687">cyhal_dac_init</a>(&amp;my_dac_obj, <a class="code hl_enumvalue" href="group__group__hal__impl__pin__package__psoc6__01__116__bga__ble.html#ggaf78d7d92acc4005cc057d8a9b48e6f28aca42e6dc954ab8b8625f87b8e37f9bf2">P9_6</a>);</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Check the return of cyhal_dac_init to confirm initialization was successful</span></div>
<div class="line">    <span class="keywordflow">if</span> (dac_result == <a class="code hl_define" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>)</div>
<div class="line">    {</div>
<div class="line">        <span class="comment">// Write the 16 bit value as DAC input</span></div>
<div class="line">        <a class="code hl_function" href="group__group__hal__dac.html#gabb6bdec361f3805b7086cef3ea3b9d56">cyhal_dac_write</a>(&amp;my_dac_obj, dac_value);</div>
<div class="line"> </div>
<div class="line">        <span class="comment">// Return the 16 bit DAC register value</span></div>
<div class="line">        dac_read = <a class="code hl_function" href="group__group__hal__dac.html#ga2ad162f2317e6f1666d7eadebbddca82">cyhal_dac_read</a>(&amp;my_dac_obj);</div>
<div class="line"> </div>
<div class="line">        <span class="keywordflow">if</span> (dac_read == 0xFFFF)</div>
<div class="line">        {</div>
<div class="line">            <span class="comment">// Insert code</span></div>
<div class="line">        }</div>
<div class="line">    }</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// Release DAC object after use by calling cyhal_dac_free, this de-initializes the DAC</span></div>
<div class="line">    <span class="comment">// (including its output)</span></div>
<div class="line"> </div>
<div class="ttc" id="agroup__group__hal__dac_html_ga2ad162f2317e6f1666d7eadebbddca82"><div class="ttname"><a href="group__group__hal__dac.html#ga2ad162f2317e6f1666d7eadebbddca82">cyhal_dac_read</a></div><div class="ttdeci">uint16_t cyhal_dac_read(cyhal_dac_t *obj)</div><div class="ttdoc">Read the current DAC output voltage setting, as a normalized unsigned 16-bit value (where 0 is the lo...</div></div>
<div class="ttc" id="agroup__group__hal__dac_html_gaa33e893eccc66deff01287434a847687"><div class="ttname"><a href="group__group__hal__dac.html#gaa33e893eccc66deff01287434a847687">cyhal_dac_init</a></div><div class="ttdeci">cy_rslt_t cyhal_dac_init(cyhal_dac_t *obj, cyhal_gpio_t pin)</div><div class="ttdoc">Initialize the DAC peripheral.</div></div>
<div class="ttc" id="agroup__group__hal__dac_html_gabb6bdec361f3805b7086cef3ea3b9d56"><div class="ttname"><a href="group__group__hal__dac.html#gabb6bdec361f3805b7086cef3ea3b9d56">cyhal_dac_write</a></div><div class="ttdeci">void cyhal_dac_write(const cyhal_dac_t *obj, uint16_t value)</div><div class="ttdoc">Set the output voltage, as a normalized unsigned 16-bit value (where 0 is the lowest value the DAC ca...</div></div>
<div class="ttc" id="agroup__group__hal__impl__hw__types_html_structcyhal__dac__t"><div class="ttname"><a href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a></div><div class="ttdoc">DAC object.</div><div class="ttdef"><b>Definition:</b> cyhal_hw_types.h:641</div></div>
<div class="ttc" id="agroup__group__hal__impl__pin__package__psoc6__01__116__bga__ble_html_ggaf78d7d92acc4005cc057d8a9b48e6f28aca42e6dc954ab8b8625f87b8e37f9bf2"><div class="ttname"><a href="group__group__hal__impl__pin__package__psoc6__01__116__bga__ble.html#ggaf78d7d92acc4005cc057d8a9b48e6f28aca42e6dc954ab8b8625f87b8e37f9bf2">P9_6</a></div><div class="ttdeci">@ P9_6</div><div class="ttdoc">Port 9 Pin 6.</div><div class="ttdef"><b>Definition:</b> cyhal_psoc6_01_116_bga_ble.h:110</div></div>
<div class="ttc" id="agroup__group__result_html_gaca79700fcc701534ce61778a9bcf57d1"><div class="ttname"><a href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a></div><div class="ttdeci">uint32_t cy_rslt_t</div><div class="ttdoc">Provides the result of an operation as a structured bitfield.</div><div class="ttdef"><b>Definition:</b> cy_result.h:438</div></div>
<div class="ttc" id="agroup__group__result_html_gaf58fac450d9fff4472f03ad68f6e546e"><div class="ttname"><a href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a></div><div class="ttdeci">#define CY_RSLT_SUCCESS</div><div class="ttdoc">cy_rslt_t return value indicating success</div><div class="ttdef"><b>Definition:</b> cy_result.h:465</div></div>
</div><!-- fragment --> <table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="groups" name="groups"></a>
API Reference</h2></td></tr>
<tr class="memitem:group__group__hal__results__dac"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__results__dac.html">DAC HAL Results</a></td></tr>
<tr class="memdesc:group__group__hal__results__dac"><td class="mdescLeft">&#160;</td><td class="mdescRight">DAC specific return codes. <br /></td></tr>
<tr class="separator:"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="enum-members" name="enum-members"></a>
Enumerations</h2></td></tr>
<tr class="memitem:gab8bd602f1b7d91eacd4126873148e5a3"><td class="memItemLeft" align="right" valign="top">enum &#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#gab8bd602f1b7d91eacd4126873148e5a3">cyhal_dac_ref_t</a> { <br />
&#160;&#160;<a class="el" href="group__group__hal__dac.html#ggab8bd602f1b7d91eacd4126873148e5a3aa38d2cb249af9c70780d9b6aaa225e24">CYHAL_DAC_REF_VDDA</a>
, <br />
&#160;&#160;<a class="el" href="group__group__hal__dac.html#ggab8bd602f1b7d91eacd4126873148e5a3af87f660f3058a173c6fbdeb24528e46f">CYHAL_DAC_REF_VREF</a>
<br />
 }</td></tr>
<tr class="memdesc:gab8bd602f1b7d91eacd4126873148e5a3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reference choices for the DAC.  <a href="group__group__hal__dac.html#gab8bd602f1b7d91eacd4126873148e5a3">More...</a><br /></td></tr>
<tr class="separator:gab8bd602f1b7d91eacd4126873148e5a3"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="func-members" name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:gaa33e893eccc66deff01287434a847687"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#gaa33e893eccc66deff01287434a847687">cyhal_dac_init</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj, <a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a> pin)</td></tr>
<tr class="memdesc:gaa33e893eccc66deff01287434a847687"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the DAC peripheral.  <a href="group__group__hal__dac.html#gaa33e893eccc66deff01287434a847687">More...</a><br /></td></tr>
<tr class="separator:gaa33e893eccc66deff01287434a847687"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga3909980f08a38f08035617bd38c6e918"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#ga3909980f08a38f08035617bd38c6e918">cyhal_dac_init_cfg</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj, const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__configurator__t">cyhal_dac_configurator_t</a> *cfg)</td></tr>
<tr class="memdesc:ga3909980f08a38f08035617bd38c6e918"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initialize the DAC peripheral using a configurator generated configuration struct.  <a href="group__group__hal__dac.html#ga3909980f08a38f08035617bd38c6e918">More...</a><br /></td></tr>
<tr class="separator:ga3909980f08a38f08035617bd38c6e918"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gae157cda193ce7fc45eb5b390e40d0d0b"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#gae157cda193ce7fc45eb5b390e40d0d0b">cyhal_dac_free</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj)</td></tr>
<tr class="memdesc:gae157cda193ce7fc45eb5b390e40d0d0b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Release the dac object.  <a href="group__group__hal__dac.html#gae157cda193ce7fc45eb5b390e40d0d0b">More...</a><br /></td></tr>
<tr class="separator:gae157cda193ce7fc45eb5b390e40d0d0b"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga0fd4a8c9b2b5e3b712904d3e63ed8a41"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#ga0fd4a8c9b2b5e3b712904d3e63ed8a41">cyhal_dac_set_reference</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj, <a class="el" href="group__group__hal__dac.html#gab8bd602f1b7d91eacd4126873148e5a3">cyhal_dac_ref_t</a> ref)</td></tr>
<tr class="memdesc:ga0fd4a8c9b2b5e3b712904d3e63ed8a41"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the DAC voltage reference.  <a href="group__group__hal__dac.html#ga0fd4a8c9b2b5e3b712904d3e63ed8a41">More...</a><br /></td></tr>
<tr class="separator:ga0fd4a8c9b2b5e3b712904d3e63ed8a41"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gabb6bdec361f3805b7086cef3ea3b9d56"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#gabb6bdec361f3805b7086cef3ea3b9d56">cyhal_dac_write</a> (const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj, uint16_t value)</td></tr>
<tr class="memdesc:gabb6bdec361f3805b7086cef3ea3b9d56"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the output voltage, as a normalized unsigned 16-bit value (where 0 is the lowest value the DAC can output and 0xFFFF is the highest)  <a href="group__group__hal__dac.html#gabb6bdec361f3805b7086cef3ea3b9d56">More...</a><br /></td></tr>
<tr class="separator:gabb6bdec361f3805b7086cef3ea3b9d56"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga1f3c2d83b1d94abc0c77bc55379459bb"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#ga1f3c2d83b1d94abc0c77bc55379459bb">cyhal_dac_write_mv</a> (const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj, uint16_t value)</td></tr>
<tr class="memdesc:ga1f3c2d83b1d94abc0c77bc55379459bb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Set the output voltage, as an unsigned number of millivolts.  <a href="group__group__hal__dac.html#ga1f3c2d83b1d94abc0c77bc55379459bb">More...</a><br /></td></tr>
<tr class="separator:ga1f3c2d83b1d94abc0c77bc55379459bb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga2ad162f2317e6f1666d7eadebbddca82"><td class="memItemLeft" align="right" valign="top">uint16_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#ga2ad162f2317e6f1666d7eadebbddca82">cyhal_dac_read</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj)</td></tr>
<tr class="memdesc:ga2ad162f2317e6f1666d7eadebbddca82"><td class="mdescLeft">&#160;</td><td class="mdescRight">Read the current DAC output voltage setting, as a normalized unsigned 16-bit value (where 0 is the lowest value the DAC can output and 0xFFFF is the highest).  <a href="group__group__hal__dac.html#ga2ad162f2317e6f1666d7eadebbddca82">More...</a><br /></td></tr>
<tr class="separator:ga2ad162f2317e6f1666d7eadebbddca82"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga7a08830e80bd91017013c5f7cf306f0d"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__hal__dac.html#ga7a08830e80bd91017013c5f7cf306f0d">cyhal_dac_set_power</a> (<a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *obj, <a class="el" href="group__group__hal__general__types.html#ga246fde0e79029f514ce3846b31e366d7">cyhal_power_level_t</a> power)</td></tr>
<tr class="memdesc:ga7a08830e80bd91017013c5f7cf306f0d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Changes the current operating power level of the DAC.  <a href="group__group__hal__dac.html#ga7a08830e80bd91017013c5f7cf306f0d">More...</a><br /></td></tr>
<tr class="separator:ga7a08830e80bd91017013c5f7cf306f0d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Enumeration Type Documentation</h2>
<a id="gab8bd602f1b7d91eacd4126873148e5a3" name="gab8bd602f1b7d91eacd4126873148e5a3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab8bd602f1b7d91eacd4126873148e5a3">&#9670;&nbsp;</a></span>cyhal_dac_ref_t</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">enum <a class="el" href="group__group__hal__dac.html#gab8bd602f1b7d91eacd4126873148e5a3">cyhal_dac_ref_t</a></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Reference choices for the DAC. </p>
<table class="fieldtable">
<tr><th colspan="2">Enumerator</th></tr><tr><td class="fieldname"><a id="ggab8bd602f1b7d91eacd4126873148e5a3aa38d2cb249af9c70780d9b6aaa225e24" name="ggab8bd602f1b7d91eacd4126873148e5a3aa38d2cb249af9c70780d9b6aaa225e24"></a>CYHAL_DAC_REF_VDDA&#160;</td><td class="fielddoc"><p >Analog supply (default) </p>
</td></tr>
<tr><td class="fieldname"><a id="ggab8bd602f1b7d91eacd4126873148e5a3af87f660f3058a173c6fbdeb24528e46f" name="ggab8bd602f1b7d91eacd4126873148e5a3af87f660f3058a173c6fbdeb24528e46f"></a>CYHAL_DAC_REF_VREF&#160;</td><td class="fielddoc"><p >Internal reference. See the BSP documentation for the reference value. </p>
</td></tr>
</table>

</div>
</div>
<h2 class="groupheader">Function Documentation</h2>
<a id="gaa33e893eccc66deff01287434a847687" name="gaa33e893eccc66deff01287434a847687"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaa33e893eccc66deff01287434a847687">&#9670;&nbsp;</a></span>cyhal_dac_init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_dac_init </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__pin__package__psoc6__01__104__m__csp__ble.html#ga707195ce0627016bf371643bdd9caa51">cyhal_gpio_t</a>&#160;</td>
          <td class="paramname"><em>pin</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the DAC peripheral. </p>
<p >By default, the reference will be set to <a class="el" href="group__group__hal__dac.html#ggab8bd602f1b7d91eacd4126873148e5a3aa38d2cb249af9c70780d9b6aaa225e24">CYHAL_DAC_REF_VDDA</a>.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a DAC object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">pin</td><td>The dac pin name </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the init request. On success returns <a class="el" href="group__group__result.html#gaf58fac450d9fff4472f03ad68f6e546e">CY_RSLT_SUCCESS</a>.<br  />
 On failure, a problem specific error code will be returned. This error could be from the HAL or lower level driver. <br  />
 For all other return codes, please refer to device driver documentation available in the BSP landing page </dd></dl>

</div>
</div>
<a id="ga3909980f08a38f08035617bd38c6e918" name="ga3909980f08a38f08035617bd38c6e918"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga3909980f08a38f08035617bd38c6e918">&#9670;&nbsp;</a></span>cyhal_dac_init_cfg()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_dac_init_cfg </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__configurator__t">cyhal_dac_configurator_t</a> *&#160;</td>
          <td class="paramname"><em>cfg</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Initialize the DAC peripheral using a configurator generated configuration struct. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[out]</td><td class="paramname">obj</td><td>Pointer to a DAC object. The caller must allocate the memory for this object but the init function will initialize its contents. </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">cfg</td><td>Configuration structure generated by a configurator. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the init request </dd></dl>

</div>
</div>
<a id="gae157cda193ce7fc45eb5b390e40d0d0b" name="gae157cda193ce7fc45eb5b390e40d0d0b"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gae157cda193ce7fc45eb5b390e40d0d0b">&#9670;&nbsp;</a></span>cyhal_dac_free()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_dac_free </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Release the dac object. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in,out]</td><td class="paramname">obj</td><td>The dac object </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga0fd4a8c9b2b5e3b712904d3e63ed8a41" name="ga0fd4a8c9b2b5e3b712904d3e63ed8a41"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga0fd4a8c9b2b5e3b712904d3e63ed8a41">&#9670;&nbsp;</a></span>cyhal_dac_set_reference()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_dac_set_reference </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__dac.html#gab8bd602f1b7d91eacd4126873148e5a3">cyhal_dac_ref_t</a>&#160;</td>
          <td class="paramname"><em>ref</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the DAC voltage reference. </p>
<p >This determines the highest value that the DAC can output.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">obj</td><td>The DAC object </td></tr>
    <tr><td class="paramname">ref</td><td>The selected voltage reference. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the reference selection request </dd></dl>

</div>
</div>
<a id="gabb6bdec361f3805b7086cef3ea3b9d56" name="gabb6bdec361f3805b7086cef3ea3b9d56"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gabb6bdec361f3805b7086cef3ea3b9d56">&#9670;&nbsp;</a></span>cyhal_dac_write()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">void cyhal_dac_write </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the output voltage, as a normalized unsigned 16-bit value (where 0 is the lowest value the DAC can output and 0xFFFF is the highest) </p>
<dl class="section note"><dt>Note</dt><dd>While the input value is 16 bits, the actual resolution that can be achieved is dependent on what the underlying hardware supports. See the device datasheet for details.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The dac object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>The 16-bit output value to set </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga1f3c2d83b1d94abc0c77bc55379459bb" name="ga1f3c2d83b1d94abc0c77bc55379459bb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1f3c2d83b1d94abc0c77bc55379459bb">&#9670;&nbsp;</a></span>cyhal_dac_write_mv()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_dac_write_mv </td>
          <td>(</td>
          <td class="paramtype">const <a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint16_t&#160;</td>
          <td class="paramname"><em>value</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Set the output voltage, as an unsigned number of millivolts. </p>
<dl class="section note"><dt>Note</dt><dd>Depending on the resolution of the underlying hardware, it may not be possible to achieve the precise voltage requested. See the device datasheet for more details about the DAC resolution.</dd></dl>
<p>It is an error to specify a value that is outside of the DAC's operating range.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The dac object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">value</td><td>The number of millivolts to output set. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the write request. </dd></dl>

</div>
</div>
<a id="ga2ad162f2317e6f1666d7eadebbddca82" name="ga2ad162f2317e6f1666d7eadebbddca82"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga2ad162f2317e6f1666d7eadebbddca82">&#9670;&nbsp;</a></span>cyhal_dac_read()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint16_t cyhal_dac_read </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Read the current DAC output voltage setting, as a normalized unsigned 16-bit value (where 0 is the lowest value the DAC can output and 0xFFFF is the highest). </p>
<p >Note: Depending on the precision of the underlying hardware, this may not precisely match the most recent value passed in to cyhal_dac_write.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>The dac object </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The 16-bit output value </dd></dl>

</div>
</div>
<a id="ga7a08830e80bd91017013c5f7cf306f0d" name="ga7a08830e80bd91017013c5f7cf306f0d"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga7a08830e80bd91017013c5f7cf306f0d">&#9670;&nbsp;</a></span>cyhal_dac_set_power()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__result.html#gaca79700fcc701534ce61778a9bcf57d1">cy_rslt_t</a> cyhal_dac_set_power </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="group__group__hal__impl__hw__types.html#structcyhal__dac__t">cyhal_dac_t</a> *&#160;</td>
          <td class="paramname"><em>obj</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="group__group__hal__general__types.html#ga246fde0e79029f514ce3846b31e366d7">cyhal_power_level_t</a>&#160;</td>
          <td class="paramname"><em>power</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>Changes the current operating power level of the DAC. </p>
<p >If the power level is set to <a class="el" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a0f601c5d5843c59e58ee1988dd0e6861">CYHAL_POWER_LEVEL_OFF</a>, the DAC will be powered-off but it will retain its configuration, so it is not necessary to reconfigure it when changing the power level from <a class="el" href="group__group__hal__general__types.html#gga246fde0e79029f514ce3846b31e366d7a0f601c5d5843c59e58ee1988dd0e6861">CYHAL_POWER_LEVEL_OFF</a> to any other value.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramdir">[in]</td><td class="paramname">obj</td><td>dac object </td></tr>
    <tr><td class="paramdir">[in]</td><td class="paramname">power</td><td>The power level to set </td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>The status of the set power request </dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>Hardware Abstraction Layer (HAL)</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
